REGISTER tw.jar;
log0 = LOAD '/hnbc/data-eth0-201307262136' USING PigStorage('\u0001') AS (line:chararray);
log1 = FOREACH log0 GENERATE FLATTEN(com.zbl.udf.LogFormat(line)) as (datetime:chararray,domain:chararray,province:chararray,type:chararray);
log2 = GROUP log1 BY type;
log3 = FOREACH log2 GENERATE group,COUNT(log1) as num;
--log4 = ORDER log3 BY num DESC;			
STORE log3 INTO '/tw/type/' USING PigStorage(); 
log4 = GROUP log1 BY province;
log5 = FOREACH log4 GENERATE group,COUNT(log1);


log6 = GROUP log1 BY (province,type);
log7 = FOREACH log6 GENERATE group.province as province,group.type as type,COUNT(log1) as num;
STORE log3 INTO '/tw/protype/' USING PigStorage(); 

logtemp = FILTER log1 BY domain!='N';
log8 = GROUP logtemp BY domain;
log9 = FOREACH log8 GENERATE group ,COUNT(logtemp) as num;
log10 = ORDER log9 BY num DESC;
STORE log10 INTO '/tw/domain/' USING PigStorage(); 

